package com.fuqi.android.zhongcai.business.shuig.view.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;

import com.fuqi.android.zhongcai.base.request.result.bean.VisitBean;
import com.fuqi.android.zhongcai.business.shuig.view.widget.AnswerView;
import com.fuqi.framework.utils.StringUtil;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Bruce on 2016/10/25.
 */
public class AnswerAdapter extends BaseAdapter {
    private Context context;
    private List<VisitBean> liststr = new ArrayList<VisitBean>();

    public AnswerAdapter(Context context, List<VisitBean> datas) {
        this.context = context;
        this.liststr = datas;
    }

    public void setDate(List<VisitBean> datas){
        liststr = datas;
        notifyDataSetChanged();
    }
    public List<VisitBean> getDate(){
        return liststr ;
    }

    public int getCount() {
        return liststr == null ? 0 : liststr.size();
    }

    public VisitBean getItem(int position) {
        return liststr.get(position);
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    public View getView(int position, View convertView, ViewGroup parent) {
        if (convertView == null) {
            convertView = new AnswerView(context);
        }
        VisitBean country = getItem(position);

        AnswerView countryView = (AnswerView) convertView;
        String name = country.getName();
        if(StringUtil.isEmpty(name)){
            name = country.getName();
        }

        countryView.setTitle(name);

        return convertView;
    }


}
